export function GetDateStr(AddDayCount) { 

   let dd = new Date();

   dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期

   let y = dd.getFullYear(); 

   let m = (dd.getMonth()+1)<10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);//获取当前月份的日期，不足10补0

   let d = dd.getDate()<10?"0"+dd.getDate():dd.getDate();//获取当前几号，不足10补0

   return y+"-"+m+"-"+d; 

}

export function getStamp(date, type = 10) {
   // 获取时间戳
   // 2019-08-30
   // 2019-08-30 15:46:07
   // 2019-08-30T15:46:07.000Z
   // 2019-08-30T15:46:07.000+08:0
   // 2019-08-30T15:46:07.000+0800
   // 2019-08-30T15:46:07.000+08:0
   // 2019-08-30T15:46:07.000+08
    let time = date.replace(/-/g, '/');
    let timestamp = new Date(time).getTime();
    return type === 10? timestamp/1000 : timestamp;
}

export function getDate(timestamp){
    timestamp = timestamp ? timestamp : null;
    let date = new Date(timestamp*1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    let Y = date.getFullYear() + '-';
    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
    let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
    let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
    return Y + M + D + h + m + s;

}